#include<iostream>
#include<unistd.h>
#include<sys/types.h>
using namespace std;
int main()
{
    pid_t id = fork();
    if(id > 0)
    {
        while(1)
        {
            cout<<"我是父进程|pid:"<<getpid()<<"|"<<"ppid:"<<getppid()<<endl;
            cout<<"====="<<endl;
            sleep(3);    
        }
    }
    else if(id == 0)
    {
        while(1)
        {
            cout<<"我是子进程|pid:"<<getpid()<<"|"<<"ppid:"<<getppid()<<endl;
            cout<<"-----"<<endl;
            sleep(3);
        }
    }
    return 0;
}
